Skip to content

Add support for alignment-baseline and dominant-baseline#68

Open
djberg96 wants to merge 1 commit intoapache:mainfrom
djberg96:text_baseline
Open

Add support for alignment-baseline and dominant-baseline#68
djberg96 wants to merge 1 commit intoapache:mainfrom
djberg96:text_baseline

Conversation

@djberg96
Copy link

@djberg96 djberg96 commented Feb 6, 2026

Courtesy of Claude Opus 4.6. I don't know Java very well or this project's details, but it's used by Vassal under the hood, so I would like to have support for these attributes.

https://issues.apache.org/jira/browse/BATIK-1306

If there's any updates or additions you would like to see, just let me know and I'll throw Claude at it.

From Claude:

Summary

Batik already had the CSS parsing infrastructure for alignment-baseline and dominant-baseline (property constants, value managers, and engine registration), but the properties were never propagated through the text rendering pipeline. Here's what was added:

  1. GVTAttributedCharacterIterator.java:313-322
    Added two new TextAttribute constants — DOMINANT_BASELINE and ALIGNMENT_BASELINE — to carry baseline values through the attributed character iterator.

  2. TextUtilities.java:289-323
    Added convertDominantBaseline() and convertAlignmentBaseline() converter methods that read the computed CSS values and return the baseline identifier string (or null for default/auto values).

  3. SVGTextElementBridge.java
    Added constant aliases for DOMINANT_BASELINE and ALIGNMENT_BASELINE
    Added both CSS property indices to SVGTextElementBridge.java:719-720 so changes trigger text re-layout
    Added reading of both properties in SVGTextElementBridge.java:1617-1628 to inject them into the ACI attribute map

  4. GlyphLayout.java
    Added constant aliases and registered both attributes in the runAtts set for run-break detection
    GlyphLayout.java:1114-1115 from the ACI during explicit glyph layout
    GlyphLayout.java:1242-1253 using dominant-baseline minus alignment-baseline and applies the result as a glyph position adjustment (horizontal offset for vertical text, vertical offset for horizontal text)
    Added GlyphLayout.java:2077-2127 helper that maps SVG baseline names to vertical offsets using font metrics: alphabetic=0, central=(ascent−descent)/2, middle≈strikethroughOffset, hanging≈80% ascent, mathematical≈strikethroughOffset+10% ascent, ideographic=−descent, text-before-edge/text-top=ascent, text-after-edge/text-bottom=−descent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant